(function(t,e,i,n){"use strict";var s=Object.freeze({none:"none",like:"like",kiss:"kiss",laugh:"laugh",wonder:"wonder",cry:"cry",angry:"angry"});var u=["like","kiss","laugh","wonder","cry","angry"];i.BitrixVue.component("bx-reaction",{props:{id:{default:""},values:{default:{}},userId:{default:0},openList:{default:true}},data:function t(){return{localValues:{},userReaction:s.none,buttonAnimate:false}},created:function t(){this.localValues=Object.assign({},this.values);n.EventEmitter.subscribe("ui:reaction:press",this.onPress)},destroy:function t(){n.EventEmitter.unsubscribe("ui:reaction:press",this.onPress)},watch:{values:function t(e){this.localValues=Object.assign({},e)}},methods:{list:function t(){if(this.openList);this.$emit("list",{values:this.localValues})},press:function t(){var e=this;var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:s.like;if(this.userReaction===s.none){if(!this.localValues[i]){this.localValues=Object.assign({},this.localValues,babelHelpers.defineProperty({},i,[]))}this.localValues[i].push(this.userId);this.buttonAnimate=true;setTimeout((function(){return e.buttonAnimate=false}),400);this.$emit("set",{action:"set",type:i})}else{if(this.localValues[this.userReaction]){this.localValues[this.userReaction]=this.localValues[this.userReaction].filter((function(t){return t!==e.userId}))}this.$emit("set",{action:"remove",type:this.userReaction})}},onPress:function t(e){var i=e.getData();if(!this.id||i.id!==this.id){return false}if(!i.emotion){i.emotion=s.like}this.press(i.emotion)}},computed:{types:function t(){var e=this;this.userReaction=s.none;return u.filter((function(t){if(typeof e.localValues[t]==="undefined"||!(e.localValues[t]instanceof Array)||e.localValues[t].length<=0){return false}if(e.userId>0&&e.userReaction===s.none&&e.localValues[t].includes(e.userId)){e.userReaction=t}return true})).map((function(t){return{type:t,count:e.localValues[t].length}}))},counter:function t(){return this.types.map((function(t){return t.count})).reduce((function(t,e){return t+e}),0)},isTypesShowed:function t(){if(this.counter<=0){return false}if(this.userReaction!==s.none&&this.counter===1){return false}return true},isMobile:function t(){var e=navigator.userAgent.toLowerCase();return e.includes("android")||e.includes("iphone")||e.includes("ipad")||e.includes("bitrixmobile")}},template:'\n\t\t<div :class="[\'ui-vue-reaction\', {\'ui-vue-reaction-mobile\': isMobile}]">\n\t\t\t<transition name="ui-vue-reaction-result-animation">\n\t\t\t\t<div v-if="isTypesShowed" class="ui-vue-reaction-result" @click="list">\n\t\t\t\t\t<transition-group tag="div" class="ui-vue-reaction-result-types" name="ui-vue-reaction-result-type-animation" >\n\t\t\t\t\t\t<span v-for="element in types" :class="[\'ui-vue-reaction-result-type\', \'ui-vue-reaction-icon-\'+element.type]" :key="element.type"></span>\n\t\t\t\t\t</transition-group>\t\n\t\t\t\t\t<div class="ui-vue-reaction-result-counter">{{counter}}</div>\n\t\t\t\t</div>\n\t\t\t</transition>\n\t\t\t<div v-if="userId > 0"  class="ui-vue-reaction-button" @click.prevent="press()">\n\t\t\t\t<div class="ui-vue-reaction-button-container">\n\t\t\t\t\t<div :class="[\'ui-vue-reaction-button-icon\', \'ui-vue-reaction-icon-\'+userReaction, {\'ui-vue-reaction-button-pressed\': buttonAnimate}]"></div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t'})})(this.window=this.window||{},BX,BX,BX.Event);
//# sourceMappingURL=reaction.bundle.map.js